styleproperties: Add _gtk_style_properties_peek_property()
authorBenjamin Otte <otte@redhat.com>
Sat, 31 Dec 2011 00:05:50 +0000 (01:05 +0100)
committerBenjamin Otte <otte@redhat.com>
Mon, 9 Jan 2012 17:37:51 +0000 (18:37 +0100)
gtk/gtkstyleproperties.c
gtk/gtkstylepropertiesprivate.h

index 26a966563ba8ab7b8d21dad387d0cb3a798836d2..08ed39bcf9df49155e94d049ed9bec72ba1adb42 100644 (file)
@@ -717,6 +717,25 @@ gtk_style_properties_set (GtkStyleProperties *props,
   va_end (args);
 }
 
+const GValue *
+_gtk_style_properties_peek_property (GtkStyleProperties      *props,
+                                     const GtkStyleProperty  *property,
+                                     GtkStateFlags            state)
+{
+  GtkStylePropertiesPrivate *priv;
+  PropertyData *prop;
+
+  g_return_val_if_fail (GTK_IS_STYLE_PROPERTIES (props), FALSE);
+  g_return_val_if_fail (property != NULL, FALSE);
+
+  priv = props->priv;
+  prop = g_hash_table_lookup (priv->properties, property);
+  if (prop == NULL)
+    return NULL;
+
+  return property_data_match_state (prop, state);
+}
+
 gboolean
 _gtk_style_properties_get_property (GtkStyleProperties *props,
                                    const gchar        *property,
@@ -724,10 +743,8 @@ _gtk_style_properties_get_property (GtkStyleProperties *props,
                                    GtkStylePropertyContext *context,
                                    GValue             *value)
 {
-  GtkStylePropertiesPrivate *priv;
   const GtkStyleProperty *node;
-  PropertyData *prop;
-  GValue *val = NULL;
+  const GValue *val;
 
   g_return_val_if_fail (GTK_IS_STYLE_PROPERTIES (props), FALSE);
   g_return_val_if_fail (property != NULL, FALSE);
@@ -740,21 +757,11 @@ _gtk_style_properties_get_property (GtkStyleProperties *props,
       return FALSE;
     }
 
-  priv = props->priv;
-  prop = g_hash_table_lookup (priv->properties, node);
-
-  val = NULL;
-
-  if (prop)
-    {
-      /* NB: Will return NULL for shorthands */
-      val = property_data_match_state (prop, state);
-    }
-
+  val = _gtk_style_properties_peek_property (props, node, state);
   g_value_init (value, node->pspec->value_type);
 
   if (val)
-    _gtk_style_property_resolve (node, props, state, context, val, value);
+    _gtk_style_property_resolve (node, props, state, context, (GValue *) val, value);
   else if (_gtk_style_property_is_shorthand (node))
     _gtk_style_property_pack (node, props, state, context, value);
   else
index 24e9714cbb7d70e2f82c0b2fb6a19149902a0885..61f940ce73f6c881418938ba069c885a531dd998 100644 (file)
@@ -39,6 +39,9 @@ void           _gtk_style_properties_get_valist               (GtkStylePropertie
                                                               GtkStylePropertyContext *context,
                                                               va_list                  args);
 
+const GValue * _gtk_style_properties_peek_property            (GtkStyleProperties      *props,
+                                                               const GtkStyleProperty  *property,
+                                                               GtkStateFlags            state);
 void           _gtk_style_properties_set_property_by_property (GtkStyleProperties      *props,
                                                                const GtkStyleProperty  *property,
                                                                GtkStateFlags            state,